package nl.boelen.game.net.packet;


public class Packet31Movement extends Packet {

    private static final int packetNumber = 31;
    private String uniqueKey;
    private byte movingDirection;
    private int x;
    private int y;

    public Packet31Movement(byte[] data) {
        super(packetNumber);
        String[] datas = (readData(data)).split(":");
        this.uniqueKey = datas[0];
        this.x = Integer.parseInt(datas[1]);
        this.y = Integer.parseInt(datas[2]);
        this.movingDirection = (byte) Integer.parseInt(datas[3]);
    }

    public Packet31Movement(String uniqueKey, int x, int y, byte movingDirection) {
        super(packetNumber);
        this.uniqueKey = uniqueKey;
        this.movingDirection = movingDirection;
        this.x = x;
        this.y = y;
    }

    @Override
    public byte[] getData() {
        return (packetNumber + this.uniqueKey + ":" + this.x + ":" + this.y + ":" + this.movingDirection).getBytes();
    }

    public String getUniqueKey() {
        return uniqueKey;
    }

    public byte getMovingDirection() {
        return movingDirection;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
}